<?php
class AddArticlePresenter {
	private $contentRepository;
	private $view;
	public function __construct($view, IArticleRepository $contentRepository) {
		$this->view = $view;
		$this->contentRepository = $contentRepository;
	}
	public function postArticle($title, $content, $userName) {
		if ($title == NULL || trim ( $title ) === 0) {
			$this->view->addArticleFailed ( "Title? What title? Exactly! " );
			return;
		}
		
		if ($content == NULL || trim ( $content ) === 0) {
			$this->view->addArticleFailed ( "No content no <s>sex</s> game! Don't forget it!" );
			return;
		}
		
		$article = Article::newInstance ( $userName );
		
		$article->setTitle ( strip_tags ( trim ( $title ) ) );
		$article->setContent ( strip_tags ( trim ( $content ) , '<p><a><br><b><i><ul><ol><li>') );
		
		$this->contentRepository->addArticle ( $article );
		
		$this->view->addArticleSucceed ( $article->getArticleId () );
	}
	
	public function getArticle($title, $content, $userName) {
		if ($title == NULL || trim ( $title ) === 0) {
			$this->view->addArticleFailed ( "Title? What title? Exactly! " );
			return;
		}
		
		if ($content == NULL || trim ( $content ) === 0) {
			$this->view->addArticleFailed ( "No content no <s>sex</s> game! Don't forget it!" );
			return;
		}
		
		$article = Article::newInstance ( $userName );
		
		$article->getTitle();
		$article->getContent();
	}
}

?>